<template>
  <Modal v-model="deleteModal" :mask-closable="false" width="360">
    <p slot="header" style="text-align: center; color: red">
      <Icon type="ios-information-circle"></Icon>
      <span>删除 确认</span>
    </p>
    <div style="text-align: left">
      <p>您即将对</p>
      <p>
        集群名称: <span style="color: red">{{ serviceInfo.name }}</span>
      </p>
      <p>
        集群描述: <span style="color: red">{{ serviceInfo.description }}</span>
      </p>
      <p>
        集群类型：<span style="color: red">{{ serviceInfo.type }}</span>
      </p>
      <p>执行<span style="color: red"> 【删除】 </span>操作</p>
      <p>确定执行该操作吗?</p>
    </div>
    <div slot="footer">
      <Button type="success" size="large" @click="ok">确认</Button>
      <Button type="default" size="large" @click="cancel">取消</Button>
    </div>
  </Modal>
</template>

<script>
import { deleteCmdbService } from '@/api/cmdb/service'
import { errorNotify } from '@/libs/util'
export default {
  name: 'DeleteModal',
  props: {
    deleteModal: {
      type: Boolean,
      default: false,
      require: true
    },
    serviceInfo: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      color: 'color:red',
      loading: false
    }
  },
  computed: {},
  mounted() {},
  created() {},
  methods: {
    ok() {
      this.loading = true
      this.deleteCmdbService(this.serviceInfo.id)
    },
    cancel() {
      this.$emit('on-service-delete', { type: 'cancel', status: false })
    },
    async deleteCmdbService(serviceId) {
      try {
        await deleteCmdbService(serviceId)
        this.$Notice.success({ title: '删除:' + this.serviceInfo.name + '成功' })
        this.$emit('on-service-delete', { type: 'delete', status: false })
      } catch (e) {
        errorNotify(e)
      } finally {
        this.loading = false
        this.$emit('on-service-delete', { type: 'delete', status: false })
      }
    }
  }
}
</script>

<style scoped></style>
